<!doctype html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<link href="css/mui.min.css" rel="stylesheet" />
		<link rel="stylesheet" type="text/css" href="css/app.css"/>
		<script src="js/mui.min.js"></script>
		<script type="text/javascript">
			mui.init()
		</script>
		<style type="text/css">
			.titleAp p{color: #333333;margin: 5px 0;}
			.titleAp p:nth-of-type(1){font-size: 18px;}
			.titleAp p:nth-of-type(2){font-size: 12px;}
			.titleAp p:nth-of-type(3){font-size: 16px;color: #FF6767;}
			.textAp p{color: #666666;line-height: 35px;border-bottom: 1px #EEEEEE dashed;}
			.textAp p:nth-of-type(1){color: #333333;font-size: 16px;font-weight: bold;}
			.textAp p:nth-of-type(1) span{color: #999999;font-size: 10px;margin: 0 0 0 3px;}
			.colorFont21{font-size: 14px;text-align: center;}
			.colorFont21+div{font-size: 14px;text-align: center;}
			.mui-table-view:after{background: none;}
			.mui-table-view:before{background: none;}
			.mui-content{margin-top: 45px;}
		</style>
	</head>
	<body>
		<div id="headerNav"></div>
		<div class="mui-content">
		  
		    <img style="padding: 11px 15px;" src="image/1ddadd4abbd793789eb0147dc57ae93c.jpg" width="100%"  alt="" />
			<p class="titleCenterS">法国原瓶进口红酒凯旋干红葡萄酒</p>
			<ul class="mui-table-view mui-grid-view">
			    <li class="mui-table-view-cell mui-media mui-col-xs-6">
			        <a href="#">
			            <img class="mui-media-object" src="http://placehold.it/400x300">
			            <div class="mui-media-body colorFont21">会呼吸的酒封</div>
			            <div class="mui-media-body">封瓶后保持呼吸 酒质香</div>
			        </a>
			    </li>
			   	<li class="mui-table-view-cell mui-media mui-col-xs-6">
			        <a href="#">
			            <img class="mui-media-object" src="http://placehold.it/400x300">
			            <div class="mui-media-body colorFont21">会呼吸的酒封</div>
			            <div class="mui-media-body">封瓶后保持呼吸 酒质香</div>
			        </a>
			    </li>
			</ul>
		    <img style="padding: 11px 15px;" src="image/1ddadd4abbd793789eb0147dc57ae93c.jpg" width="100%"  alt="" />
		</div>
		<nav class="mui-bar mui-bar-tab">
		    <p class="mui-pull-left" style="width: 30%;height: 100%;margin: 0 10px;line-height: 50px;font-size: 20px;color: #5763FF;" id="money"></p>
		    <button class="mui-pull-right" style="width: 50%;height: 50px; background: #5763FF;color: #FFFFFF;font-size: 16px;" id="btn">立即购买</button>
		</nav>
	</body>
	<script src="http://libs.baidu.com/jquery/2.0.0/jquery.min.js"></script>
	<script type="text/javascript">
		$('#headerNav').load('header.html',function(){
			$('header h1').html('详情');
		});
	</script>
	<script type="text/javascript">
		function GetQueryString(name) {
				var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
				var r = window.location.search.substr(1).match(reg);
				if(r != null) return unescape(r[2]);
				return null;
			}
			var checked = GetQueryString("id");
			console.log(checked);
		var a = localStorage.state;
		var b = localStorage.data;
			$.ajax({
				type:"post",
				url:"http://mall.itcn99.com/i/index/goods_details",
				async:true,
				dataType:'jsonp',
				data:{
					"gid":checked,
				},
				success:function(data){
					console.log(data)
					$(".mui-content").html("").append('<img src="'+data.data.goods_img+'" width="100%"  alt="" /><ul class="mui-table-view"><li class="mui-table-view-cell"><div class="mui-media-body titleAp"><p>'+data.data.goods_name+'</p><p>'+data.data.goods_specific+'</p><p style="font-weight: bold;">￥'+data.data.goods_price+'</p></div></li><li class="mui-table-view-cell"><div class="mui-media-body textAp">'+data.data.content+'</div></li></ul>')
					$("#money").html("").append('￥'+data.data.goods_price)
				}
			});
			$("#btn").click(function(){
				if(a==1){
					$.ajax({
						type:"post",
						url:"http://mall.itcn99.com/i/index/order_buy",
						async:true,
						dataType:'jsonp',
						data:{
							"gid":checked,
							"uid":b,
						},
						success:function(data){
							console.log(data)
							var state = data.state;
							
							if(state == 0){
								mui.confirm("","请先添加地址",function(e){
									if(e.index==1){
										window.location.href='add_address.html?id='+checked;
									}
								})
							}else{
								var address_id = data.data.address_info.id;
								window.location.href="confirm_order.html?id="+checked;
							}
						}
					});
				}else{
					mui.alert('','需先登录才能购买',function(){
						window.location.href='register.html'
					})
				}
				
			})
	</script>
</html>